﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using AsyncDemo.Model;

namespace AsyncDemo
{
    public class BlogContext:DbContext
    {
        public BlogContext()
            : base("name=BlogsContext")
        {

        }
        public DbSet<Blog> Blogs { get; set; }
        public DbSet<Post> Posts { get; set; }
        public DbSet<User> Users { get; set; }

        public DbSet<Comment> Comments { get; set; }

        public DbSet<Person> Persons { get; set; }


        //注意: 更改对象名的任一部分都可能会破坏脚本和存储过程。
        //更改表字段名称
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<User>()
                .Property(u => u.DisplayName)
                .HasColumnName("display_name");
        }
    }
}
